<@home.head title="字典【${dict.dictName}】的字典值信息">
	<base target="_self"> 
	<@home.common_list/>
	<script src="${basePath}/widget/validate/js/jquery.validate.min.js" type="text/javascript"></script>
	<script src="${basePath}/widget/validate/js/jquery.metadata.js" type="text/javascript"></script>
	<link rel="stylesheet" href="${basePath}/widget/validate/css/screen.css" type="text/css"/>
	<script>
		
		$().ready(function() {
			$("#inputForm").validate({event: "blur"});
		});
		var AddOptions = { 
		　　success: function(message) { 
		　　		if(message=="200")
		　　		{
					$.jBox.tip('操作成功','success',{closed:function() {submitQuery();parent.$.jBox.close('id-jbox-dialog');}});
				}else{
					$.jBox.tip('操作失败','error',{timeout:1500});
				}
		 	}
		 }; 
		
	
		var fanYe = function(pageObj){
			$("#pageNo").val($(pageObj).attr("page"));
			$("#pageSize").val($("#pageSize").val());
			submitQuery();
		};
		
		var goPage = function(){
			$("#pageNo").val($("#pageNo").val());
			$("#pageSize").val($("#pageSize").val());
			submitQuery();
		};
	
		var options = { 
			dataType:'json',
		　　success: function(data) { 
		　　		if(data.code=="200")
		　　		{
		　　			$.jBox.tip("操作成功",'success',{top:'20px',closed:function(){submitQuery()}});
				}else{
					$.jBox.tip("操作失败",'error',{top:'20px'});
				}
		 	}
		 }; 
	
	 	var deleteBatchDictValue = function(){
			var objList = $("input[type=checkbox][attrCheckAll=checkAll]:checked");
		
			if(objList.size()==0){
				$.jBox.tip('请先选择要删除的字典值','info',{closed:function() {return;}});
			}else{
				var deleteSubmit = function(v){
						if(!v){
							return true;
						}
						var len = $("input[type=checkbox][attrCheckAll=checkAll]:checked").size();
					
						/**重置表单名称*/
						var dictCheck;
						for(var index=0;index<objList.size();index++){
							dictCheck = objList[index];
							dictCheck.name="dictValueIds";
						}
						$("#inputForm").attr("action","dict_value_batchDel.shtml");
						$('#inputForm').ajaxSubmit(options); 
					}
				$.jBox.confirm("确认要删除吗 ?","操作提示",  deleteSubmit, { top:'50px',buttons: { '确定': true, '取消': false} });
			}
		};
		
		/**点击新增时复制一行tr*/
		
		var addDictValue = function(){
			var str = "<tr>	<td class=\"td_r\" style=\"width:20px;\">&nbsp;</td><td class=\"td_r\"><input type=\"text\" value='' attrName='valueCode' class=\"{required:true,rangelength:[1,40]}\" validateCode=\"validateCode\"/>&nbsp;</td>"+
						"<td class=\"td_r\"><input type=\"text\" value=''  class=\"{required:true,rangelength:[1,40]}\" attrName='valueName' validateValue=\"validateValue\"/>&nbsp;</td><td class=\"td_r\"><input type=\"text\" value='0' attrName='taxis' class=\"{required:true,range:[0,100]}\"/>&nbsp;</td><td class=\"td_r\">&nbsp;&nbsp;<a href=\"javascript:;\" onclick='removeRow(this);'>移除</a></td></tr>";
			if($(".td_noresult")){
				$(".td_noresult").remove();
				$("tbody").append(str);
			}else{
				$("tbody tr:last-child").after(str);
			}
			
			
		};
		
		/**移除一行**/
		var removeRow = function(currentObj){
			$(currentObj).parent().parent().remove();
		};
		
		/**保存数据**/
		var saveData = function(){
			var lenA =  $("input[type=text][attrName=valueCode]").size();
			var lenB = 	$("input[type=checkbox][attrCheckAll=checkAll]:checked").size();
			 if(!$('#inputForm').valid()){
				return;
		 	 }
			if(lenB+lenA==0){
				$.jBox.tip('请先勾选或新增相应的数据再保存','info',{closed:function() {return;}});
				return;
			}
			
			var len = $("input[type=checkbox][attrCheckAll=checkAll]").size();
		
			var dictValue ;
			var dictCode;
			var sort;
			
			
			/**重置表单名称*/
			for(var index=0;index<lenA;index++){
				dictCode = $("input[type=text][attrName=valueCode]")[index];
				dictValue=$("input[type=text][attrName=valueName]")[index];
				sort=$("input[type=text][attrName=taxis]")[index];
				dictValue.value=$.trim(dictValue.value);
				dictCode.value=$.trim(dictCode.value);
				dictCode.name="dictValueList["+(len+index)+"].valueCode";
				dictValue.name="dictValueList["+(len+index)+"].valueName";
				sort.value=$.trim(sort.value);
				sort.name="dictValueList["+(len+index)+"].taxis";
			}
			
			
			var editConfirm = function(v){
				if(!v){
					return true;
				}
				$("#inputForm").attr("action","dict_value_add.shtml");
				$('#inputForm').ajaxSubmit(options); 
			};
			$.jBox.confirm("确认要保存吗?如果同时要修改已存在的数据必须勾选。否则只保存新增数据","操作提示",  editConfirm, { top:'50px',buttons: { '确定': true, '取消': false} });
		};
		
		//删除字典值
		var deleteDictValue = function(id)
		 {
			var deleteSubmit = function(v){
				if(!v){
					return true;
				}
				 $.ajax({
					 dataType:'json',
					 url:'dict_value_del.shtml',
					 data:'id='+id+"&random="+Math.random(),
					 success:function(data){
						if(data.code=="200")
				　　		{
				　　			$.jBox.tip('字典值添加成功','success',{closed:function() {submitQuery();}});
						}else{
							parent.$.jBox.tip(message);
							return false;
						}
				 	}
				});
			};
			$.jBox.confirm("确认要删除吗 ?","操作提示",  deleteSubmit, { top:'50px',buttons: { '确定': true, '取消': false} });
		 };
		
		var submitQuery = function(){
			$("#inputForm").attr("action","dict_value_list.shtml");
			$("#inputForm").submit();
		};
		
	</script>
</@home.head>
<@home.body>
	<form id="inputForm" name="inputForm" method="post">
		<input type="hidden" name="dictId" value="${dict.dictId}"/>
		<table width="100%" class="listTable" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
					<th class="td_h" style="width:20px;"><input type="checkbox" onclick="checkAllByAttr(this,'attrCheckAll','checkAll')"/></th>
					<th class="td_h">字典码</th>
					<th class="td_h">字典值</th>
					<th class="td_h">排序值</th>
					<th class="td_h">操作</th>
				</tr>
			</thead>
			<tbody>
				<#if pageVO?exists && pageVO.resultList?exists >
					<#list pageVO.resultList as dictValue>
						<tr>
							<td class="td_r" style="width:20px;"><input type="hidden" name="dictValueList[${dictValue_index}].optFlag" value="update" />
							<input type="checkbox" name="dictValueList[${dictValue_index}].dictValueId" value="${dictValue.dictValueId}" attrCheckAll="checkAll" />&nbsp;</td>
							<td class="td_r"><input type="text" value="${dictValue.valueCode}" class="{required:true,rangelength:[1,40]}" name="dictValueList[${dictValue_index}].valueCode" id="dictValueList[${dictValue_index}].valueCode" validateCode="validateCode"/>&nbsp;</td>
							<td class="td_r"><input type="text" value="${dictValue.valueName}"  class="{required:true,rangelength:[1,40]}" name="dictValueList[${dictValue_index}].valueName" id="dictValueList[${dictValue_index}].valueCode" validateValue="validateValue"/>&nbsp;</td>
							<td class="td_r"><input type="text" value="${dictValue.taxis}"  class="{required:true,range:[0,1000]}" name="dictValueList[${dictValue_index}].taxis"/>&nbsp;</td>
							<td class="td_r">&nbsp;&nbsp;<a href="javascript:deleteDictValue('${dictValue.dictValueId}');">删除</a></td>
						</tr>
					</#list>
				<#else>
					<tr>
						<td class="td_noresult" colspan="8">暂无相关数据!</td>
					</tr>
				</#if>
			</tbody>
		</table>
		<div style="text-align:left;margin-top:15px;">
			<button  type="button" onclick="deleteBatchDictValue()">
				<span class="icon_exit">停用</span>
			</button>
			&nbsp;
			<button  type="button" onclick="addDictValue()">
				<span class="icon_add">新增</span>
			</button>
			&nbsp;
			<button type="button" class="button icon_word4" onclick="saveData()">
				<span class="icon_save">全部保存</span>
			</button>
			&nbsp;
			<button  type="button" onclick="parent.$.jBox.close('id-jbox-dialog')">
				<span class="icon_no">关闭</span>
			</button>
	<div>
	<#if pageVO?exists && pageVO.resultList?exists>
		<script>
			$(this).pagination({
				'rowCount':${pageVO.rowCount},
				'pageNum':${pageVO.pageNum},
				'pageNo':${pageVO.pageNo},
				'pageSize':${pageVO.pageSize},
				'firstBtnHandler':'fanYe(this)',
				'showGO':false,
				'pageHandler':'fanYe(this)'
			});
		</script>
	</#if>
	</form>
</@home.body>
